#!/usr/bin/evn python
# coding=utf-8
from typing import List, Dict

from infirmary_admin_src.infirmary_smart_admin.infirmary_models.admin_dbhelper import session_scope, session_scope_atomic
from infirmary_admin_src.infirmary_smart_admin.infirmary_models.admin_model import SysEmployee,SysMenu


class LogicBusinesses:
    pass

    @staticmethod
    def get_sys_employee_info_by_login_name(login_name)->SysEmployee:
        with session_scope():
            return SysEmployee.get_or_none(SysEmployee.login_name==login_name,SysEmployee.deleted_flag==0)

    @staticmethod
    def get_sys_employee_menuList_by_admin_role()->List[SysMenu]:
        with session_scope():
           return [v for v in SysMenu.select().dicts()]

    @staticmethod
    def get_sys_employee_authorities_by_admin_role() -> List[Dict]:
        with session_scope():
            return [{
                'authority':v.get('web_perms')
            } for v in SysMenu.select(SysMenu.web_perms).where(SysMenu.menu_type==3,SysMenu.disabled_flag==0).dicts().order_by(SysMenu.create_time.desc())]

